<template>
    <input type="text"><br>
    <a v-color1="color">12345</a>
    <button @click="changeColor">变色</button>
</template>
  
<script setup>
import {onMounted, onUnmounted, reactive, ref} from "vue";
let color=ref("purple");
    function changeColor(){
        if(color.value==="red"){
            color.value="green";
        }else{
            color.value="red"
        }
    }
    const vColor1={
        mounted:(el,binding)=>{
            el.style.color=binding.value;
        },
        updated:(el,binding)=>{
            el.style.color=binding.value;
        }
    }

    onMounted(()=>console.log("VueCommand3_Mounted"));
    onUnmounted(()=>console.log("VueCommand3_UnMounted"));
</script>

<style scoped>

</style>